/* 
 * File:   Util.h
 * Author: stuart
 *
 * Created on August 24, 2011, 1:35 PM
 */

#ifndef UTIL_H
#define	UTIL_H

#pragma once 

#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <setjmp.h>
#include <math.h>
#include "hpdf.h"
#include "Imagem.h"
#include "Pagina.h"

#define PXtoCM 28.346
#define G 0.9025

using namespace std;

class Util
{
public:
	Util();
	~Util();
	HPDF_Doc initPDF();
	HPDF_Page initPage(HPDF_Doc pdf, Pagina pag);
	void savePDF(HPDF_Doc pdf, string fileName);
	HPDF_Image loadImage(HPDF_Doc pdf, Imagem image);
	HPDF_Image loadImage2(HPDF_Doc pdf, string name);
	vector<string> getNames(string path);
	vector<double> calcWidthAndHeight(double altura, double largura, int order);
	vector<Imagem> getImages(HPDF_Doc pdf, string pathImage);
	vector<Imagem> getImages2(HPDF_Doc pdf, vector<string> pathImages);
	vector<Imagem> getImages3(HPDF_Doc pdf, vector<string> pathImages, vector<int> importancia);        
	double max(double a, double b);
	double min(double a, double b);
	double aspectRatioSideBySide(double ar, double al, double er, double el);
	double aspectRatioTop(double ar, double al, double er, double el);
	double areaProportionSideBySide(double ar, double al, double er, double el);
	double areaProportionTop(double ar, double al, double er, double el);
	double areaBB(double areaPagina, double aPagina, double aBB);
	double areaFoto(double eFoto, double ePBB, double areaPBB);
	double areaPagina(double hPagina, double wPagina);
	vector<double> alturaLarguraFoto(double areaF, double aspectRatioFoto);
	double aspectRatioFoto(double width, double height);
	double posX(double el, double al, double er, double ar);
	double posY(double eb, double ab, double et, double at);
	Imagem getImagemPorNome(vector<Imagem> im, string name);
	double getAlturaByLargura(double aspect, double largura);
	double getLarguraByAltura(double aspect, double altura);
	vector<string> readFile(string pathFile);
        string getCropp(string path, double aspect);
        vector<Imagem> loadImageList(string fileName, HPDF_Doc pdf);
};

#endif	/* UTIL_H */

